﻿Imports System.Reflection
Imports DotNetNuke

Namespace DotNetNuke.Modules.Help
    Public Class ViewHelpTutorialPresenter

#Region "Private Memebers"
        Private View As IViewHelpTutorial
        Private Controller As IHelpTutorialController
#End Region


        Public Sub New(ByVal _View As IViewHelpTutorial, ByVal _Controller As IHelpTutorialController)
            View = _View
            Controller = _Controller
        End Sub

        Public Sub OnLoaded(ByVal LoadForm As Boolean)
            'Try
            '    If LoadForm = False Then
            '        Dim HelpTutorials As List(Of HelpTutorialInfo) = Controller.(View.ModuleId)

            '        If HelpTutorials.Count = 0 Then
            '            ' add the content to the HelpTutorial table
            '            Dim objHelpTutorial As HelpTutorialInfo = New HelpTutorialInfo
            '            objHelpTutorial.ModuleId = View.ModuleId
            '            objHelpTutorial.Content = "View.Content"
            '            objHelpTutorial.CreatedByUser = View.ModuleId
            '            Controller.Add(objHelpTutorial)
            '            ' get the content from the HelpTutorial table
            '            HelpTutorials = Controller.GetByModules(View.ModuleId)
            '        End If
            '        ' bind the content to the repeater
            '        View.HelpTutorials = HelpTutorials
            '    End If
            'Catch exc As Exception
            '    View.Exception = exc
            'End Try
        End Sub

        Public Function PrepareCurrentRow(ByVal _HelpTutorialInfo As HelpTutorialInfo) As String
            Dim strContent As String = ""

            ' add content to template
            'If CType(Settings("template"), String) <> "" Then
            'strContent = CType(Settings("template"), String)
            Dim objProperties As Dictionary(Of String, PropertyInfo) = Common.Utilities.CBO.GetProperties(Of HelpTutorialInfo)()
            Dim intProperty As Integer
            Dim objPropertyInfo As PropertyInfo
            For intProperty = 0 To objProperties.Count - 1
                objPropertyInfo = CType(objProperties(intProperty), PropertyInfo)
                strContent = strContent.Replace("[" & objPropertyInfo.Name.ToUpper & "]", DataBinder.Eval(_HelpTutorialInfo, objPropertyInfo.Name).ToString())
            Next intProperty
            'strContent = DataBinder.Eval(_HelpTutorialInfo, "Content")
            Return strContent
        End Function

    End Class
End Namespace


